#include "widget.h"
#include "ui_widget.h"
#include<fstream>
#include<QFile>
#include<QTextStream>
#include<QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
//    std::ifstream file("E:/code_commit/qt/comboBox_3/test.txt");
    QFile file("E:/code_commit/qt/comboBox_3/test.txt");
    std::string line;
    if(file.open(QIODevice::ReadOnly|QIODevice::Text))
    {
        QTextStream in(&file);
        while(!in.atEnd())
        {
            QString line=in.readLine();
            if(!line.isEmpty())
            {
                 ui->comboBox->addItem(line);
            }
        }
        file.close();
    }
    else
    {
        qDebug()<<"打开文件失败："<<file.errorString();
    }

}

Widget::~Widget()
{
    delete ui;
}

